



class Route:
  def __init__(self):
    self.msg_map = {}

  def Insert(self, msgid, callback):
    msg_map = self.msg_map
    msg_map[msgid] = callback

  def Remove(self, msgid):
    del msg_map[msgid]

  def Dispatch(self, msgid, args):
    msg_map = self.msg_map
    if not msg_map.has_key(msgid):
      return False
    callback = msg_map[msgid]
    callback(args)
    return TRUE

  def Clear(self):
    msg_map = self.msg_map
    msg_map.clear()


def test1(*kw):
  print 'test1'

def test2(*kw):
  print 'test2'

if __name__ == '__main__':
  route = Route()
  route.Insert(100, test1)
  route.Insert(100, test2)
  route.Clear()
  route.Dispatch(100, 'hello')
